package service

import (
	"singo/model"
	"singo/serializer"
)

// DemandShowService 需求详情的服务
type DemandShowService struct {
}

// DemandShow 需求
func (service *DemandShowService) DemandShow(uid string) serializer.Response {
	var demand model.Demand
	err := model.DB.First(&demand, "uid = ?", uid).Error
	if err != nil {
		return serializer.Response{
			Status: 404,
			Msg:    "需求不存在",
			Error:  err.Error(),
		}
	}

	return serializer.Response{
		Data: serializer.BuildDemand(demand),
	}
}
